wayland_device->pointer_grab_window = window;
wayland_device->pointer_grab_time = time_;
-
- /* FIXME: This probably breaks if you end up with multiple grabs
- * on the same window - but we need to know the input device for
- * when we are asked to map a popup window so that the grab can
- * be managed by the compositor.
- */
- _gdk_wayland_window_set_device_grabbed (window,
- device,
- wayland_device->wl_seat,
- time_);
+ _gdk_wayland_window_set_grab_seat (window, GDK_SEAT (wayland_device));
g_clear_object (&wayland_device->cursor);
gdk_wayland_device_update_window_cursor (wayland_device);
if (wayland_device->pointer_grab_window)
- _gdk_wayland_window_set_device_grabbed (wayland_device->pointer_grab_window,
- NULL,
- NULL,
- 0);
+ _gdk_wayland_window_set_grab_seat (wayland_device->pointer_grab_window,
+ NULL);
}
}
GdkGeometry geometry_hints;
GdkWindowHints geometry_mask;
- guint32 grab_time;
- GdkDevice *grab_device;
- struct wl_seat *grab_input_seat;
+ GdkSeat *grab_input_seat;
gint64 pending_frame_counter;
guint32 scale;
* grab before showing the popup window.
*/
if (impl->grab_input_seat)
- return impl->grab_input_seat;
+ return gdk_wayland_seat_get_wl_seat (impl->grab_input_seat);
/* HACK: GtkMenu grabs a special window known as the "grab transfer window"
* and then transfers the grab over to the correct window later. Look for
{
tmp_impl = GDK_WINDOW_IMPL_WAYLAND (attached_grab_window->impl);
if (tmp_impl->grab_input_seat)
- return tmp_impl->grab_input_seat;
+ return gdk_wayland_seat_get_wl_seat (tmp_impl->grab_input_seat);
}
while (transient_for)
tmp_impl = GDK_WINDOW_IMPL_WAYLAND (transient_for->impl);
if (tmp_impl->grab_input_seat)
- return tmp_impl->grab_input_seat;
+ return gdk_wayland_seat_get_wl_seat (tmp_impl->grab_input_seat);
transient_for = tmp_impl->transient_for;
}
return NULL;
}
+static struct wl_seat *
+find_default_input_seat (GdkWindow *window)
+{
+ GdkDisplay *display;
+ GdkSeat *seat;
+
+ display = gdk_window_get_display (window);
+ seat = gdk_display_get_default_seat (display);
+
+ return gdk_wayland_seat_get_wl_seat (seat);
+}
+
static gboolean
should_be_mapped (GdkWindow *window)
{
*/
if (!impl->transient_for && impl->hint == GDK_WINDOW_TYPE_HINT_POPUP_MENU)
{
- GdkDevice *grab_device;
+ GdkDevice *grab_device = NULL;
/* The popup menu window is not the grabbed window. This may mean
* that a "transfer window" (see gtkmenu.c) is used, and we need
* the "transfer window" can be retrieved via the
* "gdk-attached-grab-window" associated data field.
*/
- if (!impl->grab_device)
+ if (!impl->grab_input_seat)
{
GdkWindow *attached_grab_window =
g_object_get_data (G_OBJECT (window),
{
GdkWindowImplWayland *attached_impl =
GDK_WINDOW_IMPL_WAYLAND (attached_grab_window->impl);
- grab_device = attached_impl->grab_device;
+ grab_device = gdk_seat_get_pointer (attached_impl->grab_input_seat);
transient_for =
gdk_device_get_window_at_position (grab_device,
NULL, NULL);
}
else
{
- grab_device = impl->grab_device;
+ grab_device = gdk_seat_get_pointer (impl->grab_input_seat);
transient_for =
gdk_device_get_window_at_position (grab_device, NULL, NULL);
}
/* If the position was not explicitly set, start the popup at the
* position of the device that holds the grab.
*/
- if (!impl->position_set)
- gdk_window_get_device_position (transient_for,
- impl->grab_device,
+ if (!impl->position_set && grab_device)
+ gdk_window_get_device_position (transient_for, grab_device,
&window->x, &window->y, NULL);
}
else
if (!grab_input_seat)
{
- g_warning ("Couldn't map window %p as popup because no grabbed seat found",
+ g_warning ("No grabbed seat found, using the default one in "
+ "order to map popup window %p. You may find oddities "
+ "ahead, gdk_seat_grab() should be used to "
+ "simultaneously grab input and show this popup",
window);
-
- create_fallback = TRUE;
+ grab_input_seat = find_default_input_seat (window);
}
}
}
void
-_gdk_wayland_window_set_device_grabbed (GdkWindow *window,
- GdkDevice *device,
- struct wl_seat *seat,
- guint32 time_)
+_gdk_wayland_window_set_grab_seat (GdkWindow *window,
+ GdkSeat *seat)
{
GdkWindowImplWayland *impl;
g_return_if_fail (window != NULL);
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
-
- impl->grab_device = device;
impl->grab_input_seat = seat;
- impl->grab_time = time_;
}
/**